<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="lib/react.development.js"></script>
	<script src="lib/react-dom.development.js"></script>
	<script src="lib/babel.min.js"></script>
	<style>
		#root button{
			padding:5px;
			margin:5px;
		}
		#root button.active{
			background: red;
		}
		#root div{
			width: 500px;
			height: 300px;
			border:1px solid green;
		}
	</style>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
	// zhangpeiyue
	const root = ReactDOM.createRoot(document.querySelector("#root"));
	class App extends React.Component{
		state = {
			activeIndex:1
		}
		render(){
			const {activeIndex} = this.state;
			return (
				<>
					<button onClick={()=>this.setState({activeIndex:0})} className={activeIndex===0?"active":""}>娱乐</button>
					<button onClick={()=>this.setState({activeIndex:1})} className={activeIndex===1?"active":""}>体育</button>
					<button onClick={()=>this.setState({activeIndex:2})} className={activeIndex===2?"active":""}>财经</button>
					<div style={{display:activeIndex===0?"block":"none"}}>娱乐新闻</div>
					<div style={{display:activeIndex===1?"block":"none"}}>体育新闻</div>
					<div style={{display:activeIndex===2?"block":"none"}}>财经新闻</div>
				</>
			)
		}
	}
	root.render(<App/>)
</script>
</html>